home *** CD-ROM | disk | FTP | other *** search
-
- Internet Magazine cover CD, May 98 - Java scripts
-
-
-
- A bit easier than tediously copying the scripts
- printed in the magazine, rather cut and paste the
- code below to use in your own Web pages.
-
-
- Can it make a cup of coffee and walk the dog...?
-
-
- Creating a Timeout
- ------------------
-
- <BODY BACKGROUND="" BGCOLOR="#ffffff">
- <CENTER>
- <IMAGE SRC = libya1.jpg WIDTH = 300 HEIGHT = 239>
- </CENTER>
- <SCRIPT LANGUAGE=JavaScript>
- window.setTimeout('location="minute_change2.html";',60000);
- </SCRIPT>
- </BODY>
-
-
- Getting a random number
- -----------------------
-
- function random(max)
- { today=new Date();
- áá hour=today.getHours();
- áá min=today.getMinutes();
- áá sec=today.getSeconds();
- áá return(((sec) % max)+1);}
-
-
- Creating an array
- -----------------
-
- function setuparray(num)
- { this.length = num;
- for (loop=1; loop <= num; loop++);
- { this[loop]=0; }
- return this;}
-
-
- Playing the slideshow
- ---------------------
-
- <HTML>
- <HEAD>
- <TITLE>Random slideshow</TITLE>
- <SCRIPT Language=JavaScript>
- /* Create an array */
- function setuparray(num)
- { this.length = num;
- for (loop=1; loop <= num; loop++);
- { this[loop]=0; }
- return this;}
- /* Get a random number */
- function random(max)
- { today=new Date();
- áá hour=today.getHours();
- áá min=today.getMinutes();
- áá sec=today.getSeconds();
- áá return(((sec) % max)+1);}
- function display()
- { picturenum=random(5);
- window.setTimeout('location="minute_change3.html"',20010);
- document.writeln('<CENTER><IMG SRC='+slideshow[picturenum]+' WIDTH=300 HEIGHT=239></CENTER>');
- }
- </SCRIPT>
- </HEAD>
- <BODY BACKGROUND="" BGCOLOR="#ffffff">
- <SCRIPT LANGUAGE=JavaScript>
- /* Create an array to store addresses of pictures */
- slideshow = new setuparray(5);
- slideshow[1]="libya1.jpg";
- slideshow[2]="libya2.jpg";
- slideshow[3]="libya3.jpg";
- slideshow[4]="libya4.jpg";
- slideshow[5]="libya5.jpg";
- display();
- </SCRIPT>
- </BODY>
- </HTML>
-
-
- The finishing touches
- ---------------------
-
- 1
-
- <FRAMESET COLS=300,* BORDER=0 FRAMEBORDER=0>
- áá <FRAMESET ROWS=225,* BORDER=0 FRAMEBORDER=0>
- <FRAME SRC=slideshow1.html MARGINWIDTH=0
- MARGINHEIGHT=0 NAME=picture SCROLLING=NO>
- <FRAME SRC=null.html MARGINWIDTH=0 MARGINHEIGHT=0áááá
- NAME=textá SCROLLING=NO>
- áá </FRAMESET>
- <FRAME SRC=slideshow2.html MARGINWIDTH=0 MARGINHEIGHT=0 NAME=main>
- </FRAMESET>
-
- 2
-
- <HEAD>
- <TITLE>A framed slideshow</TITLE>
- <SCRIPT Language=JavaScript>
- /* Create an array */
- function setuparray(num)
- { this.length = num;
- for (loop=1; loop <= num; loop++);
- { this[loop]=0; }
- return this;}
- /* Get a random number */
- function random(max)
- { num=0;
- á while (num<1||num>max) num=0 + parseInt(Math.random() * max);
- á return(num);}
- function display()
- /* Get a random number */
- { picturenum=0;
- while(slideshow[picturenum]==null) picturenum=random(5);
- window.setTimeout('location="slideshow1.html"',20010);
- /* Display the picture in the array at the position indicated by the random
- number */
- parent.text.document.clear();
- parent.text.document.writeln('<H2><BR>'+slidetext[picturenum]+'<BR>
- </H2>');
- document.writeln('<CENTER><IMG SRC='+slideshow[picturenum]+'
- WIDTH=300 HEIGHT=225></CENTER>');
- }
- </SCRIPT>
- </HEAD>
- <BODY BACKGROUND="" BGCOLOR="#ffffff">
- <SCRIPT LANGUAGE=JavaScript>
- /* Create an array to store addresses of pictures */
- slideshow = new setuparray(5);
- slidetext = new setuparray(5);
- /* Load the array with the picture addresses */
- slideshow[1]="emiratesbank.jpg";
- slideshow[2]="duskboats.jpg";
- slideshow[3]="flowers.jpg";
- slideshow[4]="fishmarket.jpg";
- slideshow[5]="fishroundabout.jpg";
- /* Load the text */
- slidetext[1]="The glass front of the Emirates Bank is a familiar landmark in Dubai";
- slidetext[2]="Passage across the 'Creek' is by tiny passenger boats which ply back and forth until late at night";
- slidetext[3]="Although a desert country, careful maintenance ensures Dubai city is always full of flowers";
- slidetext[4]="The Arabian Gulf is a rich source of food fish";
- slidetext[5]="The fish roundabout is a well known landmark, celebrating the rich food supply of the Gulf";
- display();
- </SCRIPT>
- </BODY>
- </HTML>
-
-
-